<template>
	<view class="content" v-if="data">
		<u-navbar :is-back="false" back-icon-color="#333" :background="background" back-text="首页" title="首页"
			title-color="#fff" :back-text-style="{ color: '#fff' }">
		</u-navbar>
		<!-- <u-swiper :list="data.bannerlist" :effect3d="true" :height="300"></u-swiper> -->
		<view class="m_top25" v-for="(listitem, index) in data.menus" :key="index" v-show="$rule(listitem.show)">
			<u-section :title="listitem.title" :right="false" :show-line="true"></u-section>
			<view class="white m_top5">
				<u-grid :col="3" :border="false">
					<u-grid-item v-for="(item, idx) in listitem.info" :key="idx" v-show="$rule(item.show)"
						@tap="onClick(item.url ? item.url : null)">
						<image class="u-grid-item-img" :src="item.src"></image>
						<view class="grid-text">{{ item.title }}</view>
					</u-grid-item>
				</u-grid>
			</view>
		</view>
		
	</view>
</template>
<script>
var _this
export default {
	data() {
		return {
			background: {
				backgroundColor: '#334285',
			},
			// data: null,
			data: {
				menus: [
					{
						title: '商品管理',
						show: 'spgl',
						info: [
							{
								title: '商品分类',
								src: '../../static/gn/s01.png',
								url: '/pages/commodity/type',
								show: 'shangpin/fenlei',

							},
							{
								title: '商品信息',
								src: '../../static/gn/s02.png',
								url: '/pages/commodity/commodityinfo',
								show: 'shangpin/xinxi',

							},
							{
								title: '商品单位',
								src: '../../static/gn/s03.png',
								url: '/pages/commodity/unit',
								show: 'shangpin/danwei',

							},
						]

					},
					{
						title: '基础信息',
						show: 'jcxx',

						info: [
							{
								title: '供应商管理',
								src: '../../static/gn/j1.png',
								url: '/pages/information/supplier/supplierlist',
								show: 'gongyingshang',

							},
							{
								title: '仓库分区',
								src: '../../static/gn/j2.png',
								url: '/pages/information/partition/index',
								show: 'changkufenqu',

							},
							{
								title: '仓库信息',
								src: '../../static/gn/j3.png',
								url: '/pages/information/warehouse/index',
								show: 'cangkuxinxi',

							},
							{
								iconname: 'bookmark-fill',
								title: '客户信息',
								src: '../../static/gn/j4.png',
								url: '/pages/information/customerinfo/index',
								show: 'kehuxinxi',

							},
							// {
							// 	iconname: 'bookmark-fill',
							// 	title: '销售出库（发货）',
							// 	src: '../../static/gn/j5.png',
							// 	url: '/pages/sell/addorder',
							// 	show: 'xiaoshouchuku',

							// },
							{
								iconname: 'bookmark-fill',
								title: '我的客户',
								src: '../../static/gn/j6.png',
								url: '/pages/information/mycustomerinfo/index',
								show: 'wodekehu',

							},
						]

					},
					{
						title: '采购管理',
						show: 'cggl',

						info: [
							{
								title: '采购入库',
								src: '../../static/gn/c1.png',
								url: '/pages/purchase/addorder',
								show: 'caigouruku',

							},
							{
								title: '采购订单',
								src: '../../static/gn/c2.png',
								url: '/pages/purchase/order',
								show: 'caigoudingdan',

							},
							{
								title: '采购退单',
								src: '../../static/gn/c3.png',
								url: '/pages/purchase/addretire',
								show: 'caigoutuidan',

							},
							{
								title: '退货单',
								src: '../../static/gn/c4.png',
								url: '/pages/purchase/retire',
								show: 'tuihuodan',
							},
						]

					},
					// {
					// 	title: '销售管理',
					// 	show: 'xsgl',

					// 	info: [
					// 		{
					// 			title: '销售开单',
					// 			src: '../../static/gn/x1.png',
					// 			url: '/pages/sell/addorder',
					// 			show: 'xiaoshoudingdan',

					// 		},
					// 		{
					// 			title: '销售订单',
					// 			src: '../../static/gn/x2.png',
					// 			url: '/pages/sell/order',
					// 			show: 'xiaoshouchuku',
					// 		},

					// 	]

					// },


				],
			}
		}
	},
	onLoad() {
		_this = this
		
	},
	methods: {
		onClick(url) {
			if (url) {
				uni.navigateTo({
					url: url,
				})
			}
		},
		getmenus() {
			console.log('运行了')
			_this._post_form('api/index/getmenus', {}, (result) => {
				// _this.data = result.data
			})
		},
		onClickMp() {
			return
		},
		/**
		 * 分享当前页面
		 */
		onShareAppMessage: function () {
			return {
				title: '我发现了一个超好用的进销存管理系统',
				path: '/pages/login/index',
			}
		},
		/**
		 * 分享到朋友圈
		 * 本接口为 Beta 版本，暂只在 Android 平台支持，详见分享到朋友圈 (Beta)
		 * https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share-timeline.html
		 */
		onShareTimeline() {
			return {
				title: '我发现了一个超好用的进销存管理系统',
				path: '/pages/login/index',
			}
		},
	},
}
</script>
<style>
.content {
	padding: 10px 10px;
}

.grid-text {
	font-size: 28rpx;
	margin-top: 4rpx;
	color: #333;
}

.m_top15 {
	margin-top: 15px;
}

.m_top25 {
	margin-top: 25px;
}

.m_top5 {
	margin-top: 5px;
}

.u-grid-item-img {
	margin: 0 auto;
	display: block;
	padding: 5px 0;
	width: 28px;
	height: 28px;
}
</style>
